<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1. 箭头函数没有prototype ,原型
        let A = () => { }
        console.log(A.prototype)
        // 2. 不能使用new调用箭头函数，也就是它不能作为构造函数
        // let b = () => {}
        // let c = new b()

        // 3. 箭头函数没有arguments对象，可以利用rest接收剩余参数
        let a = (first, ...rest) => {
            console.log(first, rest)
        }
        a(123, 1, 2, 3)

        // 4. 箭头函数本身没有this，
        // 箭头函数的this在定义的时候就确定了，指向的是上层作用域中的this

        let msg = '666'  // let声明的变量，不会挂载到window上
        let obj = {
            msg: 'xxx',
            say: function () {
                console.log('say: ', this.msg)  // say: xxx
            },
            sayHi: () => {
                console.log('sayHi: ', this.msg) // sayHi: undefined   window.msg
            }
        }
        obj.say()
        obj.sayHi()
    </script>
</body>

</html>